#ifndef __PARAMETER_NORMAL_OPERATER_H__
#define __PARAMETER_NORMAL_OPERATER_H__
#include <typescommon.h>

#if DEVICE_PLATFORM_CONFIGURE != DEVICE_PLATFORM_C51_MCU
#pragma pack(1)
#endif
struct paramHeadComStc
{
    uint16_t psize;
    uint16_t pcrc;
};

enum PARAM_CFG_LEVEL_ENUM
{
    PARAM_CFG_LEVEL_0 = 0, // level high, reset all param.
    PARAM_CFG_LEVEL_1,
    PARAM_CFG_LEVEL_2,
    PARAM_CFG_LEVEL_3,
    PARAM_CFG_LEVEL_4,
    PARAM_CFG_LEVEL_5, // defualt level
    PARAM_CFG_LEVEL_6,
    PARAM_CFG_LEVEL_7,
    PARAM_CFG_LEVEL_8,
    PARAM_CFG_LEVEL_9,
};

#define paramGetDataSize(paramStruct) (sizeof(paramStruct) - sizeof(struct paramHeadComStc))
#define parmGetDataPtr(pnPtr) ((char *)pnPtr + sizeof(struct paramHeadComStc))
#define parmCaclHeadCrc(prmval) calcSumCrc16(((const uint8_t *)&prmval) + sizeof(struct paramHeadComStc), prmval.phead.psize);
#define parmCalcHeadInf(prmval)                          \
    {                                                    \
        prmval.phead.psize = (paramGetDataSize(prmval)); \
        prmval.phead.pcrc = parmCaclHeadCrc(prmval);     \
    }

//================================default normal param begin=============================================
#define PARM_NORMAL_CHK_FLAG 0
struct parmInfoNorStc
{
    struct paramHeadComStc phead;
    char sn[LT_CMD_SN_MAX_SIZE];
    uint8_t addr485;
    uint8_t loglev;
#if PARM_NORMAL_CHK_FLAG
    uint16_t chkparam;
#endif
};
int parmNormPrint();
int parmNormReset(int configLevel);
void parmNormSave();
void parmNormRead();
extern struct parmInfoNorStc parmNormIstc;
//================================default normal param end=============================================

#if DEVICE_PLATFORM_CONFIGURE != DEVICE_PLATFORM_C51_MCU
#pragma pack()
#endif
#endif
